#include <stdio.h>
#include <time.h>

#define N 3

int a[3][3]={{1,2,3},
	     {1,2,3},
	     {1,2,3}};

void sum1(int a[N][N], int sum){
	int i, j;
	sum=0;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			sum+=a[i][j];
		}
	}
}

void sum2(int a[N][N], int sum){
	int i, j;
	sum=0;
	for(j=0;j<N;j++){
		for(i=0;i<N;i++){
			sum+=a[i][j];
		}
	}
}

int main(){
	clock_t time1, time2, time3;
	long temp=10000000, all1, all2;
	double dur1,dur2,ave1,ave2;
	int x=0, y=0;
	all1=temp;
	all2=temp;
	time1=clock();
	while(all1!=0){
		sum1(a,x);
		all1--;
	}
	time2=clock();
	while(all2!=0){
		sum2(a,y);
		all2--;
	}
	time3=clock();
	dur1=(double)(time2-time1)/CLOCKS_PER_SEC;
	dur2=(double)(time3-time2)/CLOCKS_PER_SEC;
	printf("time to run sum1 %d loop is %f seconds\n", temp, dur1);
	printf("time to run sum2 %d loop is %f seconds\n", temp, dur2);
	return 0;
}
